<html>
<head><meta charset="utf-8"><title>transitive validity of references · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html">transitive validity of references</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160871149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871149">(Mar 15 2019 at 12:50)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> in the lang meeting there were some questions about checking the validity of references transitively, and arguments about whether they should be shallow or deep. I don't understand how we could check the validity of references if their validity would depend on the validity of the pointee, e.g., <code>&amp;[T]</code> would need us to check that all <code>T</code>s in the slice are valid for <code>&amp;[T]</code> to be valid</p>



<a name="160871193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871193">(Mar 15 2019 at 12:51)</a>:</h4>
<p>e.g. <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> argued that the deepness that we check is at most N (e.g. 5)</p>



<a name="160871364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871364">(Mar 15 2019 at 12:52)</a>:</h4>
<p>I suppose this did not mean that we would only check the first N elements of <code>&amp;[T]</code>, but that we could check at most <code>&amp;[&amp;[&amp;[&amp;[&amp;[T]]]]]</code></p>



<a name="160871411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871411">(Mar 15 2019 at 12:53)</a>:</h4>
<p>so if each slice has M elements, we'd need to check M^N values for slices</p>



<a name="160871464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871464">(Mar 15 2019 at 12:54)</a>:</h4>
<p>even with N=1 this sounds unrealistic to me</p>



<a name="160871500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871500">(Mar 15 2019 at 12:55)</a>:</h4>
<p>the only realistic option is N=0 which means reference validity is shallow checked, e.g., they are properly aligned, non-zero, but not that their pointee must be valid</p>



<a name="160871521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871521">(Mar 15 2019 at 12:55)</a>:</h4>
<p>maybe we could check that the pointee has the appropriate layout - e.g. that the memory bounds of the pointee are ok, but that's it.</p>



<a name="160871617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871617">(Mar 15 2019 at 12:57)</a>:</h4>
<p>(deleted)</p>



<a name="160871710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160871710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160871710">(Mar 15 2019 at 12:58)</a>:</h4>
<p>so when casting <code>&amp;[u8] as &amp;[bool]</code>miri wouldn't check if the bools are invalid, it would only check it when the bools are actually accessed</p>



<a name="160872147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160872147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160872147">(Mar 15 2019 at 13:03)</a>:</h4>
<p>Maybe for code that uses no slices we can check more, but a lot of code uses Vec or String which get coerced to slices often.</p>



<a name="160872287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160872287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160872287">(Mar 15 2019 at 13:05)</a>:</h4>
<p>so I don't know, if we require validity of references to be transitive, but we can't check it in practice, i wonder if it wouldn't be better to adjust the validity rules of references to not require transitivity</p>



<a name="160885350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160885350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160885350">(Mar 15 2019 at 15:31)</a>:</h4>
<p>yes I think we meant "5 levels of references"</p>



<a name="160885354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160885354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160885354">(Mar 15 2019 at 15:31)</a>:</h4>
<p>and yes that could still be expensive</p>



<a name="160886003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886003">(Mar 15 2019 at 15:38)</a>:</h4>
<p>do we gain any optimization power from requiring the pointee of a valid reference to be valid ?</p>



<a name="160886070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886070">(Mar 15 2019 at 15:39)</a>:</h4>
<p>yes. we can optimize away a function taking <code>&amp;!</code> as input (this was requested by <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> )</p>



<a name="160886080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886080">(Mar 15 2019 at 15:39)</a>:</h4>
<p>I have some thoughts for other ways to achieve this, but they are a bit hacky.</p>



<a name="160886241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886241">(Mar 15 2019 at 15:41)</a>:</h4>
<p>I think this also helps reasoning about unsafe code (e.g. if you see a reference you know that the pointee is valid), otherwise use pointers.</p>



<a name="160886340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886340">(Mar 15 2019 at 15:42)</a>:</h4>
<p>this means that you can always dereference a reference in unsafe code</p>



<a name="160886373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886373">(Mar 15 2019 at 15:43)</a>:</h4>
<p>otherwise, you can only dereference one if the pointee is valid, which might not be easy or cheap to check</p>



<a name="160886408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886408">(Mar 15 2019 at 15:43)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> what thoughts?</p>



<a name="160886429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886429">(Mar 15 2019 at 15:43)</a>:</h4>
<p>we could try to cache these checks</p>



<a name="160886448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886448">(Mar 15 2019 at 15:44)</a>:</h4>
<p>but beyond that..</p>



<a name="160886591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886591">(Mar 15 2019 at 15:45)</a>:</h4>
<p>making caching efficient would probably involve a lot of work</p>



<a name="160886700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886700">(Mar 15 2019 at 15:46)</a>:</h4>
<blockquote>
<p>otherwise, you can only dereference one if the pointee is valid, which might not be easy or cheap to check</p>
</blockquote>
<p>true. OTOH, it's not like the stronger validity makes this any easier. it just moves the same work to the point when you create a reference: when turning a raw ptr to a ref, you now must know the pointee is valid, which might not be easy or cheap to check</p>



<a name="160886808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160886808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160886808">(Mar 15 2019 at 15:48)</a>:</h4>
<blockquote>
<p>we could try to cache these checks</p>
</blockquote>
<p>that's actually made <em>much harder</em> by recursive validity, because now changing something in memory could make any random reference invalid if you can reach that memory from it</p>



<a name="160887174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160887174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160887174">(Mar 15 2019 at 15:52)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> what thoughts?</p>
</blockquote>
<p>basically: (1) validity is "pure", does not depend on memory at all; references are valid if they are non-null and aligned; (2) any further property is enforced by Stacked Borrows, which (as part of reborrowing) already "dereferences" references (to update the tags of the memory they point to). Stacked Borrows depends on the <em>layout</em> of the pointee -- it has to, to determine the size. we could add a simple but hacky extra condition saying that moreove, if that layout is of Abi type "uninhabited", then we have UB. that'd get us <span class="user-mention" data-user-id="127859">@Taylor Cramer</span>'s optimization.</p>



<a name="160888447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160888447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160888447">(Mar 15 2019 at 16:06)</a>:</h4>
<p>I see. So in a nutshell validity does not guarantee that we can do <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> optimization, stacked borrows does.</p>



<a name="160888837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160888837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160888837">(Mar 15 2019 at 16:11)</a>:</h4>
<p>and not just the <code>&amp;!</code> thing, even the <code>dereferencable</code> attribute would source from Stacked Borrows, as opposed to validity.</p>



<a name="160888868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160888868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160888868">(Mar 15 2019 at 16:11)</a>:</h4>
<p>this would mean validity does not depend on memory and can be fully cached -- validity and "bitlist validity" coincide</p>



<a name="160888937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160888937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160888937">(Mar 15 2019 at 16:12)</a>:</h4>
<p>however it also makes me wonder if the distinction between validity and Stacked Borrows is even meaningful^^</p>



<a name="160892038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160892038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160892038">(Mar 15 2019 at 16:49)</a>:</h4>
<p>would stacked borrows require that references are always dereferenceable ? </p>
<p>E.g. would <code>let unused: &amp;[bool] = transmute(&amp;[3_u8, 4, 5]);</code> "check" under stacked borrows if <code>unused</code> is never used ?</p>



<a name="160892178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160892178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160892178">(Mar 15 2019 at 16:50)</a>:</h4>
<p>Would re-borrrowing there dereference <code>unused</code> ?</p>



<a name="160944041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160944041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160944041">(Mar 16 2019 at 09:33)</a>:</h4>
<blockquote>
<p>would let unused: &amp;[bool] = transmute(&amp;[3_u8, 4, 5]); "check" under stacked borrows if unused is never used ?</p>
</blockquote>
<p>yes. after every assignment of reference types (and currently more, but I am thinking maybe that was overeager?), we do retagging. retagging asserts that the reference is dereferencable.</p>



<a name="160944042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160944042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160944042">(Mar 16 2019 at 09:33)</a>:</h4>
<p>oh wait.</p>



<a name="160944047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160944047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160944047">(Mar 16 2019 at 09:33)</a>:</h4>
<p>so, it'd check that the reference is derefencable (though I'd prefer ifw e could get unsized types out of the equation here, they might change things)</p>



<a name="160944087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160944087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160944087">(Mar 16 2019 at 09:34)</a>:</h4>
<p>but it'll <em>not</em> check whether these are valid <code>bool</code> because it doesnt check that the pointee is valid. it just checks that the pointee is allocated.</p>



<a name="160945413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945413">(Mar 16 2019 at 10:14)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> so by dereferenceable we just check that the allocation satisfies the layout (e.g. that it is large enough to be dereferenced), but not that the memory is valid, right?</p>



<a name="160945430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945430">(Mar 16 2019 at 10:15)</a>:</h4>
<p>correct</p>



<a name="160945435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945435">(Mar 16 2019 at 10:15)</a>:</h4>
<p><code>dereferncable</code> as LLVM attribute means that there's memory there that can be read from (without incurring data races or so)</p>



<a name="160945439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945439">(Mar 16 2019 at 10:15)</a>:</h4>
<p>at least that's my interpretation -- based on what it is used for: inserting spurious loads</p>



<a name="160945443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945443">(Mar 16 2019 at 10:15)</a>:</h4>
<p>so I don't think there are any issues with making this part of validity</p>



<a name="160945444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945444">(Mar 16 2019 at 10:15)</a>:</h4>
<p>egh, sorry. LLVM doesnt consider read-write races UB. so I guess the racy part doesnt matter.</p>



<a name="160945489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945489">(Mar 16 2019 at 10:16)</a>:</h4>
<p>as in, for a reference to be valid it must point to an allocation that's sufficiently large to fit the layout</p>



<a name="160945491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945491">(Mar 16 2019 at 10:16)</a>:</h4>
<p>well, it's somewhat a matter of redundancy -- if stacked borrows checks this anyway (as a side-effect), then why <em>also</em> check it in validity?</p>



<a name="160945493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945493">(Mar 16 2019 at 10:16)</a>:</h4>
<p>in particular when there are benefits from making validity a property that looks at the value only, not at the rest of memory</p>



<a name="160945503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945503">(Mar 16 2019 at 10:17)</a>:</h4>
<p>in the implementation it wouldn't be checked twice, but conceptually, it might be worth to teach this as part of validity</p>



<a name="160945509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945509">(Mar 16 2019 at 10:17)</a>:</h4>
<p>we should layer what kind of unsafe code people can write with different amounts of knowledge</p>



<a name="160945510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945510">(Mar 16 2019 at 10:17)</a>:</h4>
<p>well I was also speaking conceptually</p>



<a name="160945545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945545">(Mar 16 2019 at 10:18)</a>:</h4>
<p>for the spec</p>



<a name="160945553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945553">(Mar 16 2019 at 10:18)</a>:</h4>
<p>teaching can diverge from the spec though</p>



<a name="160945556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945556">(Mar 16 2019 at 10:18)</a>:</h4>
<p>validity is something that pretty much everybody using zeroed / uninitialized / maybeuninit will need to know, but stacked borrows would be a level higher</p>



<a name="160945559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945559">(Mar 16 2019 at 10:18)</a>:</h4>
<p>right but that's not an argument to <em>specify</em> things this way</p>



<a name="160945561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945561">(Mar 16 2019 at 10:18)</a>:</h4>
<p>only to <em>teach</em> them this way</p>



<a name="160945563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945563">(Mar 16 2019 at 10:18)</a>:</h4>
<p>right</p>



<a name="160945564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945564">(Mar 16 2019 at 10:18)</a>:</h4>
<p>and we're talking about the spec here, I think. that was my assumption anyway.</p>



<a name="160945567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945567">(Mar 16 2019 at 10:19)</a>:</h4>
<p>let's defer the teaching part until we have a spec^^</p>



<a name="160945574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945574">(Mar 16 2019 at 10:19)</a>:</h4>
<p>thinking about this, while teaching, we don't have to use the word validity</p>



<a name="160945577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945577">(Mar 16 2019 at 10:19)</a>:</h4>
<p>well people want us to change that word anyway</p>



<a name="160945579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945579">(Mar 16 2019 at 10:19)</a>:</h4>
<p>so <span class="user-mention" data-user-id="126931">@centril</span> issue isn't necessary to rename validity in the spec</p>



<a name="160945580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945580">(Mar 16 2019 at 10:19)</a>:</h4>
<p>"initialization invariant" (or "initialziedness" or something like that... is there a less awkward equivalent?) is my current favourite</p>



<a name="160945582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945582">(Mar 16 2019 at 10:19)</a>:</h4>
<p>they want a different name that they can use informally, while programming or teaching, but the spec doesn't need to match that necessarily</p>



<a name="160945638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945638">(Mar 16 2019 at 10:20)</a>:</h4>
<p>it's nice if the names match, but it isn't a must, e.g., C programmers don't say x has a trap representation / indeterminate value, they just say x contains garbage or "is not initialized"</p>



<a name="160945640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945640">(Mar 16 2019 at 10:20)</a>:</h4>
<p>Using one term with users and another one in the spec will confuse everyone who goes from being taught about this to reading the spec themselves, which should hopefully be many people</p>



<a name="160945647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945647">(Mar 16 2019 at 10:20)</a>:</h4>
<p>The C standard's level of difficulty is not a good bar to aspire to imo :)</p>



<a name="160945649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945649">(Mar 16 2019 at 10:20)</a>:</h4>
<blockquote>
<p>it's nice if the names match, but it isn't a must, e.g., C programmers don't say x has a trap representation / indeterminate value, they just say x contains garbage or "is not initialized"</p>
</blockquote>
<p>well also in C nobody knows how these terms <em>really</em> relate</p>



<a name="160945651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945651">(Mar 16 2019 at 10:20)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> initialization invariant sounds good to me</p>



<a name="160945656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945656">(Mar 16 2019 at 10:21)</a>:</h4>
<p>so maybe let's not use C as the example for this...</p>



<a name="160945660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945660">(Mar 16 2019 at 10:21)</a>:</h4>
<p>i was just arguing that the terms are not required to match</p>



<a name="160945663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945663">(Mar 16 2019 at 10:21)</a>:</h4>
<p>well you gave an example for a case where they dont match and things are rather messy</p>



<a name="160945664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945664">(Mar 16 2019 at 10:21)</a>:</h4>
<p>seems like an argument to make them match :P</p>



<a name="160945713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945713">(Mar 16 2019 at 10:22)</a>:</h4>
<p><code>MaybeDoesNotSatisfyTheInitializationInvariant&lt;T&gt;</code> :D</p>



<a name="160945716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945716">(Mar 16 2019 at 10:22)</a>:</h4>
<p>we're not talking about type names again are we?^^</p>



<a name="160945718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945718">(Mar 16 2019 at 10:23)</a>:</h4>
<p>which reminds me I should push stabilizing that thing...</p>



<a name="160945773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive%20validity%20of%20references/near/160945773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/transitive.20validity.20of.20references.html#160945773">(Mar 16 2019 at 10:24)</a>:</h4>
<p>and push the place value etc. PR!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>